package com.autumn.log.service.services.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.autumn.common.api.application.dto.output.IPageQueryResult;
import com.autumn.common.api.application.dto.output.PageQueryResult;
import com.autumn.log.service.LogService;
import com.autumn.log.service.domain.LogBiz;
import com.autumn.log.service.domain.entities.ServiceLogData;
import com.autumn.log.service.dto.input.ServiceLogDataDto;
import com.autumn.log.service.dto.input.ServiceLogDataQueryInput;
import com.autumn.util.AutoMapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 日志服务
 *
 * @author 老码农
 * <p>
 * 2018-02-01 20:36:42
 */
@Service(interfaceClass = LogService.class)
@Component
public class LogServiceImpl implements LogService {

    @Autowired
    private LogBiz logBiz;

    @Override
    public IPageQueryResult<ServiceLogDataDto> queryByPage(ServiceLogDataQueryInput input) {
        IPageQueryResult<ServiceLogData> result = logBiz.queryByPage(input);
        PageQueryResult<ServiceLogDataDto> pageResult =
                new PageQueryResult<>(result.getCurrentPage(), result.getPageSize(), result.getRowTotal());
        List<ServiceLogDataDto> data = AutoMapUtils.mapList(result.getItems(), ServiceLogDataDto.class);
        pageResult.setItems(data);
        return pageResult;
    }
}
